#region File Description
//-----------------------------------------------------------------------------
// CharacterClass.cs
//
// Microsoft XNA Community Game Platform
// Copyright (C) Microsoft Corporation. All rights reserved.
//-----------------------------------------------------------------------------
#endregion

#region Using Statements
using System;
using System.Collections.Generic;
using Microsoft.Xna.Framework.Content;
#endregion

namespace MilwormsGameData
{
    /// <summary>
    /// The definition of a type of character.
    /// </summary>
    public class CharacterClass : ContentObject
    {
        #region Description


        /// <summary>
        /// The name of the character class.
        /// </summary>
        private string name;

        /// <summary>
        /// The name of the character class.
        /// </summary>
        public string Name
        {
            get { return name; }
            set { name = value; }
        }


        #endregion

        /// <summary>
        /// Entries of the requirements and rewards for each level of this class.
        /// </summary>
        private List<CharacterLevelDescription> levelEntries =
            new List<CharacterLevelDescription>();

        /// <summary>
        /// Entries of the requirements and rewards for each level of this class.
        /// </summary>
        public List<CharacterLevelDescription> LevelEntries
        {
            get { return levelEntries; }
            set { levelEntries = value; }
        }

        #region Value Data


        /// <summary>
        /// The base experience value of Npcs of this character class.
        /// </summary>
        /// <remarks>Used for calculating combat rewards.</remarks>
        private int baseExperienceValue;

        /// <summary>
        /// The base experience value of Npcs of this character class.
        /// </summary>
        /// <remarks>Used for calculating combat rewards.</remarks>
        public int BaseExperienceValue
        {
            get { return baseExperienceValue; }
            set { baseExperienceValue = value; }
        }

        #endregion


        #region Content Type Reader


        /// <summary>
        /// Reads a CharacterClass object from the content pipeline.
        /// </summary>
        public class CharacterClassReader : ContentTypeReader<CharacterClass>
        {
            /// <summary>
            /// Reads a CharacterClass object from the content pipeline.
            /// </summary>
            protected override CharacterClass Read(ContentReader input,
                CharacterClass existingInstance)
            {
                CharacterClass characterClass = existingInstance;
                if (characterClass == null)
                {
                    characterClass = new CharacterClass();
                }

                characterClass.AssetName = input.AssetName;

                characterClass.Name = input.ReadString();
                characterClass.LevelEntries.AddRange(
                   input.ReadObject<List<CharacterLevelDescription>>());
                characterClass.BaseExperienceValue = input.ReadInt32();

                return characterClass;
            }
        }


        #endregion
    }
}
